function solve(board){
    let m = board[0].length
    let n = board.length

    function judgeSideIsO(i, j){
        if(i >=0 && j>= 0 &&i< n && j <m){
            if(board[i][j] === 'O'){
                board[i][j] = 'N'
                // 上下左右都判断一遍
                judgeSideIsO(i+1, j)
                judgeSideIsO(i-1, j)
                judgeSideIsO(i,j+1)
                judgeSideIsO(i, j-1)
            }
        }
        
    }
    // 从上往下、从下到上
    for(let j=0; j<m; j++){
        judgeSideIsO(0, j)
        judgeSideIsO(n-1, j)
    }


    // 从左往右、从右到左
    for(let i=0; i<n; i++){
        judgeSideIsO(i, 0)
        judgeSideIsO(i, m-1)
    }

   
    console.log(board)
  
    //遍历二维数组，将所有的O转化为X，所有的N转化为O
    for(let i=0; i<n; i++){
        for(let j=0; j<m; j++){
            if(board[i][j] === 'O'){
                board[i][j] = 'X'
            }else if(board[i][j] === 'N'){
                board[i][j] = 'O'
            }
        }
    }


}
let board = [["O","X","X","O","X"],["X","O","O","X","O"],["X","O","X","O","X"],["O","X","O","O","O"],["X","X","O","X","O"]]
solve(board)